<?php
/*
 * Controller/FancyboxController.php
 * CakePHP Fancybox Plugin
 *
 * Copyright (c) 2012 destinydriven (Kurn La Montagne)
 *
 * Author email: d3stinydriv3n@gmail.com 
 *
 * Licensed under MIT
 * http://www.opensource.org/licenses/mit-license.php
 */

App::uses('CakeEmail', 'Network/Email');

class ContactoController extends AppController {

	public $helpers = array('Html','Js', 'Fancybox.Fancybox');        
	
	public function index()
	{
		$this->layout = 'popUpContacto'; 
	}
    
    public function sendMailContact(){
        if ( !empty( $this->request->data ) ){
            $email = new CakeEmail();
            $email->config('gmail');
            $email->from( 'elalmacen60@gmail.com' );
            $email->to( $this->request->data['to'] );
            $email->subject( $this->request->data['subject'] );                  
            if( $email->send( $this->request->data['mensaje'] ) ){
                $this->Session->setFlash( __('mensaje enviado con exito'), 'default', array('class' => 'success') );
            }else {
                                $this->Session->setFlash('No se ha podido guardar el ususario, intente de nuevo.');
                        }            
            
        }
    }
	
}